package com.example.findtherinbow;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Bundle;
import android.view.View;

import com.example.findtherinbow.adapter.LeaderBoardAdapter;
import com.example.findtherinbow.utils.GsonUtil;
import com.example.findtherinbow.utils.SharedPreferencesUtil;

import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class LeaderBoardActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_leader_board);

        String jsonStr = SharedPreferencesUtil.getString(LeaderBoardActivity.this, PlayerActivity.SAVE_SCORE_RECORDS, null);

        if (jsonStr == null) {
            return;
        }

        RecyclerView mRecyclerView = findViewById(R.id.mRecyclerView);
        List<Player> list = GsonUtil.getInstance().jsonToList(jsonStr, Player.class);


        LeaderBoardAdapter mAdapter = new LeaderBoardAdapter(LeaderBoardActivity.this, list);
        mRecyclerView.setLayoutManager(new LinearLayoutManager(LeaderBoardActivity.this));
        mRecyclerView.setAdapter(mAdapter);

    }
}